<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>定时器</title>
	<script type="text/javascript">

		// setTimeout的简写方法
		var timer = setTimeout(function (){

			alert('hello!');

		},1000);
		// 关掉定时器
		clearTimeout(timer);


		// 反复执行
		var timer = setInterval(function (){

			alert('hi!');

		},2000)
		clearInterval(time2);
	</script>
</head>
<body>
	
</body>
</html>